import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddWorkspaceStatus1740876000000 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    // 创建枚举类型
    await queryRunner.query(`
      CREATE TYPE "workspace_status_enum" AS ENUM ('active', 'inactive', 'deleted');
    `);
    
    // 添加status字段到workspaces表
    await queryRunner.query(`
      ALTER TABLE "workspaces" 
      ADD COLUMN "status" "workspace_status_enum" NOT NULL DEFAULT 'active';
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    // 移除字段
    await queryRunner.query(`
      ALTER TABLE "workspaces" DROP COLUMN "status";
    `);
    
    // 删除枚举类型
    await queryRunner.query(`
      DROP TYPE "workspace_status_enum";
    `);
  }
} 